package net.oaktoncc.snippet

import scala.xml.NodeSeq
import net.liftweb.http.S._
import net.liftweb.http.RequestVar
import net.liftweb.util.Helpers._
import net.liftweb.util.{Can, Full, Empty}

class HelloForm {
  object who extends RequestVar(Full("world"))
  
  def show(xhtml: NodeSeq): NodeSeq = {
    bind("hello", xhtml,
        "whoField" --> text(who.openOr(""), v => who(v)) % ("size" -> "10") % ("id" -> "whoField"),
        "submit" --> submit(?("Send"), ignore => {println("value:" + who.openOr("") + " :: " + param("whoField"))}),
        "who" --> who.openOr("")
    )
  }
}